/// Use "YouGov2020_w3_replicationdata.csv"


//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Manuscript - mean rural identity scores //////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/// Mean rural identity scores ("rasocid") by rural residence now ("rurallive") and grew up rural ("ruralgrow")
tabstat rasocid if rurallive==1 & ruralgrow==1
tabstat rasocid if rurallive==0 & ruralgrow==1
tabstat rasocid if rurallive==1 & ruralgrow==0
tabstat rasocid if rurallive==0 & ruralgrow==0

tabstat rasocid [aweight=weight] if rurallive==1 & ruralgrow==1
tabstat rasocid [aweight=weight] if rurallive==0 & ruralgrow==1
tabstat rasocid [aweight=weight] if rurallive==1 & ruralgrow==0
tabstat rasocid [aweight=weight] if rurallive==0 & ruralgrow==0

//////////////////////////////////////////////////////////////////////////////////////////////////////////




//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ONLINE APPENDIX Table S6 and Figure S2 /////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/// "rasocid" = rural identity, "rurallive" = rural resident, "ruralgrow" = grew up rural, "inc" = income level, "college" = college degree attained, "black" = Black respondent, "hisp" = Hispanic respondent, "white" = White respondent, "female" = Female respondent, "age" = age of respondent, "relig" = religious attendance, "bornagain" = Born Again christian, "ethno" = difference in Black and White feeling thermometers
reg rasocid rurallive ruralgrow [pweight=weight]
est store r1
reg rasocid rurallive ruralgrow inc college black hisp white female age bornagain relig ethno [pweight=weight]
est store r2
reg rasocid i.rurallive##i.ruralgrow inc college black hisp white female age bornagain relig ethno [pweight=weight]
est store r3
/// Figure:
margins, at(rurallive=(0 1) ruralgrow=(0 1))
marginsplot, scheme(s1mono)
// Table:
esttab r1 r2 r3 using "Tablecspprurall.rtf", ///
        cells(b (star fmt(2) vacant("-")) se(par(( )))) ///
        starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2 pr2 N)
//////////////////////////////////////////////////////////////////////////////////////////////////////////





//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ONLINE APPENDIX Table S14  /////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/// "rasocid" = rural identity wave 1, "rasocidw3" = rural identity wave 3, "rurallive" = rural resident, "ruralgrow" = grew up rural, "inc" = income level, "college" = college degree attained, "black" = Black respondent, "hisp" = Hispanic respondent, "white" = White respondent, "female" = Female respondent, "age" = age of respondent, "relig" = religious attendance, "bornagain" = Born Again christian, "ethno" = difference in Black and White feeling thermometers, "raceid" = strength and importance of racial identity, "race" = respondent race, "pid_7" = partisanship, "ideo" = symbolic ideology -- these are from wave 1 unless otherwise specified

reg rasocidw3 rasocid inc college i.race female age bornagain relig pid_7 ideo ethno raceid ruralgrow [pweight=weight_w3] if rurallive==1
est store cspp2
reg rasocidw3 rasocid inc college i.race female age bornagain relig pid_7 ideo ethno raceid ruralgrow [pweight=weight_w3] if rurallive==0
est store cspp4
reg rasocidw3 c.raceid##i.race rasocid inc college female age bornagain relig pid_7 ideo ethno ruralgrow [pweight=weight_w3] if rurallive == 1
margins, at(race=(0 1 2 3 4) raceid=(0 1) )
marginsplot, scheme(s1mono)
est store cspp7a
reg rasocidw3 c.raceid##i.race rasocid inc college female age bornagain relig pid_7 ideo ethno ruralgrow [pweight=weight_w3] if rurallive == 0
margins, at(race=(0 1 2 3 4) raceid=(0 1) )
marginsplot, scheme(s1mono)
est store cspp8a

esttab cspp2 cspp4 cspp7a cspp8a  using "Tablecspp2020lsfdd.rtf", ///
        cells(b (star fmt(2) vacant("-")) se(par(( )))) ///
        starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2 pr2 N) 
		
//////////////////////////////////////////////////////////////////////////////////////////////////////////





//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ONLINE APPENDIX Table S15  /////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/// "rasocid" = rural identity, "rurallive" = rural resident, "ruralgrow" = grew up rural, "inc" = income level, "college" = college degree attained, "black" = Black respondent, "hisp" = Hispanic respondent, "white" = White respondent, "female" = Female respondent, "age" = age of respondent, "relig" = religious attendance, "bornagain" = Born Again christian, "ethno" = difference in Black and White feeling thermometers wave 1, "ethno3" = difference in Black and White feeling thermometers wave 3, "raceid" = strength and importance of racial identity wave 1, "race" = respondent race, "raceidw3" = strength and importance of racial identity wave 3, "pid_7" = partisanship wave 1,  "pid73" = partisanship wave 3, "ideo" = symbolic ideology, "weight_w3" = survey weight wave 3 -- these are from wave 1 unless otherwise specified

reg raceidw3 c.rasocid##i.race inc college female age bornagain relig pid_7 ideo ethno raceid ruralgrow [pweight=weight_w3] if rurallive == 1
est store cspp7
reg raceidw3 c.rasocid##i.race inc college female age bornagain relig pid_7 ideo ethno raceid ruralgrow [pweight=weight_w3] if rurallive == 0
est store cspp8
reg ethno3 rasocid ethno inc college i.race female age bornagain relig pid_7 ideo raceid ruralgrow [pweight=weight_w3] if rurallive==1
est store cspp9
reg ethno3 rasocid ethno inc college i.race female age bornagain relig pid_7 ideo raceid ruralgrow [pweight=weight_w3] if rurallive==0
est store cspp10
reg pid73 rasocid ethno inc college i.race female age bornagain relig pid_7 ideo raceid ruralgrow [pweight=weight_w3] if rurallive==1
est store cspp11
reg pid73 rasocid ethno inc college i.race female age bornagain relig pid_7 ideo raceid ruralgrow [pweight=weight_w3] if rurallive==0
est store cspp12

esttab cspp7 cspp8 cspp9 cspp10 cspp12 cspp12 using "Tablecspp20othe2r.rtf", ///
        cells(b (star fmt(2) vacant("-")) se(par(( )))) ///
        starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2 pr2 N)  
		
//////////////////////////////////////////////////////////////////////////////////////////////////////////





//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ONLINE APPENDIX Table S16 - left column ////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

tabstat rasocid, stat(mean sd)
tab rasocid

///////////////////////////////////////////////////////////////////////////////////////////////////////
















''!
////////!!!!!!!!!!!!!!!!!!!!!//////////////////////////////////////////////////
/// Use "YouGov2020_w1_replicationdata.csv"




//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ONLINE APPENDIX Table S8 and Figure S4 /////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/// "rasocid" = rural identity, "rurallive" = rural resident, "ruralgrow" = grew up rural, "inc" = income level, "college" = college degree attained, "black" = Black respondent, "hisp" = Hispanic respondent, "white" = White respondent, "female" = Female respondent, "age" = age of respondent, "relig" = religious attendance, "bornagain" = Born Again christian, "ethno" = difference in Black and White feeling thermometers, "raceid" = strength and importance of racial identity, "racen" = respondent race

reg rasocid inc college black hisp white female age bornagain relig ethno [pweight=weight] if rurallive==1
est store a1
reg rasocid inc college black hisp white female age bornagain relig ethno [pweight=weight] if rurallive==0
est store a2
reg rasocid inc college black hisp white female age bornagain relig ethno ruralgrow [pweight=weight] if rurallive==1
est store a3
reg rasocid inc college black hisp white female age bornagain relig ethno ruralgrow [pweight=weight] if rurallive==0
est store a4
reg rasocid inc college female age bornagain relig ruralgrow ethno c.raceid##i.racen [pweight=weight] if rurallive==1
est store a5
reg rasocid inc college female age bornagain relig ruralgrow ethno c.raceid##i.racen [pweight=weight] if rurallive==0
est store a6

/// Table:
esttab a1 a2 a3 a4 a5 a6 using "Tablecspp2020m.rtf", ///
        cells(b (star fmt(2) vacant("-")) se(par(( )))) ///
        starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2 pr2 N)

/// Figure:
reg rasocid c.raceid##i.racen [pweight=weight] if rurallive==1
margins, at(racen = (0 1 2 3 4) raceid=(0 1))
marginsplot, scheme(s1mono)

reg rasocid c.raceid##i.racen [pweight=weight] if rurallive==0
margins, at(racen = (0 1 2 3 4) raceid=(0 1))
marginsplot, scheme(s1mono)
//////////////////////////////////////////////////////////////////////////////////////////////////////////

	



	
//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ONLINE APPENDIX Table S16 - right column ///////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////

/// wave 1:
tabstat rasocid, stat(mean sd)
tab rasocid 

///////////////////////////////////////////////////////////////////////////////////////////////////////











